#include <iostream>
#include <string>
using namespace  std;
int main() {
    std::string input;
    std::string ch;
    std::getline(std::cin, input);
    std::getline(std::cin, ch);
    char first = ch[0];
    int size = 0;
    for (char character : input) {
        if (std::tolower(character)== std::tolower(first) ){
            size++;
        }
    }
    std::cout << size;
    return 0;
}
